<template>
    <div id="frozen">
		<view class="uni-padding-wrap uni-common-mt">
			<form>
				<view class="uni-form-item uni-column">
					<text class="title">冻结资金账户</text>
					<text class="right_text">{{cash}}</text>
				</view>
				<view class="uni-form-item uni-column apply_money">
					<span class='require'>*</span>
					<text class="title especal">申请解冻金额</text>
					<input class="uni-input" name="amount" v-model="appcash" placeholder="请输入解冻的金额"/>
				</view>
				<div class="lab_line">
					<p class="alert_apply">解冻金额不能大于您当前冻结资金</p>
				</div>
				<view class="uni-form-item uni-column">
					<text class="title especal">解冻描述</text>
					<input class="uni-input" name="amount" v-model="withdradesc" placeholder="请输入解冻描述"/>
				</view>
				<p class="alert_form">请说明解冻原由，方便平台审核</p>
			</form>
		</view>
		<footer>
			<ul class="operation">
				<li @click="reset">重置</li>
				<li @click="savemsg">保存</li>
			</ul>
		</footer>
    </div>
</template>

<script>
import { setfrozen } from '@/api/payment'
export default {
	name: 'frozenCash',
	data() {
		return {
			cash: 0,
			appcash: '',
			withdradesc: '',
			owner_user_id: ''
		}
	},
	onLoad(opcation) {
		console.log(opcation)
		this.cash = opcation.cash
		this.owner_user_id = opcation.owner_user_id
	},
	mounted() {

	},
	methods: {
		reset() {
			this.appcash = ''
			this.withdradesc = ''
		},
		msg(msg) {
			uni.showToast({
				title: msg,
				icon: 'none'
			})
		},
		savemsg() {
			if (this.appcash == '') {
				this.msg('请输入冻结金额')
			} else if (this.appcash > this.cash) {
				this.msg('冻结金额不能大于当前余额')
			} else {
				let pragrams = {
					ru_id: this.owner_user_id,
					frozen_money: this.appcash,
					seller_note: this.withdradesc
				}
				setfrozen(pragrams).then(res => {
					if (res.status == 'success') {
						this.msg('操作成功！')
						setTimeout(() => {
							uni.redirectTo({
								url: `/pages/material/recharge/materialAsset?owner_user_id=${this.owner_user_id}`
							})
						}, 500)
					} else {
						this.msg(res.errors.message)
					}
				})
			}
		}
	}
}
</script>

<style scoped lang="scss">
	.uni-padding-wrap{
		width: 750px;
		height: auto;
		padding: 0;
		display: flex;
		background: white;
	}
	#frozen .uni-form-item {
		width: 690px;
		margin: 0 30px;
		display: block;
		float:left;
		padding: 20px 0;
		font-size: 25px;
		border-bottom: 1px solid #eeeeee;
	}
	#frozen .uni-form-item:last-child{
		border-bottom:none;
	}
	#frozen .apply_money{
		border-bottom:none;
	}
	#frozen .title {
		width: 30%;
		float: left;
		display: inline;
		padding-left: 0;
	}
	#frozen .especal{
		width: 28%;
	}
	.require{
		float: left;
		color:red;
		/*		line-height: 60px;*/
		margin-right: 2px;
		padding: 10px 0;
	}
	#frozen .uni-column .uni-input {
		float: left;
		display: inline;
	}
	.right_text{
		float: right;
	}
	.lab_line{
		height: 50px;
		width: 100%;
		float: left;
		line-height: 50px;
		background: #F5F5F5;
		text-indent: 30px;
	}
	.alert_apply{
		color: #FF343A;
	}
	.alert_form{
		color: #999999;
		margin: 10px 30px;
		float: left;
	}
	.operation li{
		height: 100%;
		float: left;
		line-height: 100px;
		font-size: 32px;
		text-align: center;
	}
	.operation li:first-child{
		width: 30%;
	}
	.operation li:nth-child(2){
		color: #3A1B04;
		width: 70%;
		background: #FFD11A;
	}
</style>
